package com.cjw.pojo.dto.livesquare;

import lombok.Data;

import java.util.ArrayList;
import java.util.List;

/**
 * @author : cjw
 * @date: : 2022/2/19 15:30
 * @description : 协同算法用户计划类
 */
@Data
public class UserPlanCFDTO {
    private Long userId;

    private List<PlanCFDTO> planCFDTOList = new ArrayList<>();

    public UserPlanCFDTO() {}

    public UserPlanCFDTO(Long userId) {
        this.userId = userId;
    }

    public UserPlanCFDTO(Long userId, List<PlanCFDTO> planCFDTOList) {
        this.userId = userId;
        this.planCFDTOList = planCFDTOList;
    }

    public UserPlanCFDTO set(Long planId, int score) {
        this.planCFDTOList.add(new PlanCFDTO(planId, score));
        return this;
    }

    public PlanCFDTO find(Long plnId) {
        for (PlanCFDTO planCFDTO : planCFDTOList) {
            if (plnId == planCFDTO.getPlanId()) {
                return planCFDTO;
            }
        }
        return null;
    }
}
